﻿using System;
using System.Collections.Generic;

namespace Inovout
{
    public static class Comparer
    {
        private static readonly Dictionary<Type, object> typeDefaultValueDictionary = new Dictionary<Type, object>();
        static Comparer()
        {
            typeDefaultValueDictionary.Add(typeof(int), default(int));
            typeDefaultValueDictionary.Add(typeof(string), string.Empty);

        }
  
        public static bool DefaultValueEquals(object value)
        {
            return value == null || typeDefaultValueDictionary[value.GetType()].Equals(value);
    
        }

        public static bool Equals(string value1, string value2)
        {
            return (
                (string.IsNullOrEmpty(value1) && string.IsNullOrEmpty(value2)) || 
                (((!string.IsNullOrEmpty(value1)) && (!string.IsNullOrEmpty(value2))) && value1.Equals(value2)));
 
 //           return ((value1 == value2) || (((!string.IsNullOrEmpty(value1)) && (!string.IsNullOrEmpty(value2))) && value1.Equals(value2)));
        }

        //private static bool EqualsCore(object value1, object value2)
        //{
        //    Object value1Object = value1 ?? new Object();
        //    return value1Object.Equals(value2);
        //}
  
        //public static bool Equals<TValue>(TValue value1, TValue value2)
        //{
        //    Type valueType = typeof(TValue);
        //    if (valueType.IsValueType)
        //    {
        //        return value1.Equals(value2);
        //    }
        //    else if (valueType.Equals(typeof(string)))
        //    {
        //        return EqualsCore(value1 as string, value2 as string);
        //    }
        //    else
        //    {
        //        return EqualsCore(value1 as object, value2 as object);
        //    }


        //}
    }
}
